<?php session_start(); $_SESSION['page'] = 'admin';?>
<?php
    $userType = $_COOKIE['userType'];
    $libraryNo = $_COOKIE['libraryNo'];
?>

<!doctype html public "-//W3C//DTD HTML 4.01//EN">

<html>

   <head>
      <title>Administrator Entry</title>
      <meta http-equiv="generator" content="PHP Designer 2005" />
        <style type="text/css">
        @import url(style.css);
      </style>
   </head>

   <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000" class=''>

   <script LANGUAGE=javascript>

     function check()
     {
        if(document.search_form.userName.value=="" || document.search_form.firstName.value=="" || document.search_form.lastName.value=="" || document.search_form.middleName.value=="" || document.search_form.password.value=="")
        {
          alert('Please fill the necessary boxes.');
          return false;
        }
        return true;
     }
    </script>
    
        <table width='80%' align='center' class='content'>
            <tr><td colspan='2'><img src='images/banner.jpg'></td></tr>
            <tr><td align='right' colspan='2' class='logout'><?php require ('loginout.php');?></td></tr>
            <tr class='menuborder'><td width='90%'><img src='images/adminentry.png'></td><td><?php  require('buttons.php'); ?></td></tr>
            <tr><td colspan='2' class='bodyborder'>
             <form name='search_form' method='POST' action='save.php?page=admin' onSubmit="return check();">
                <table width='60%' align='center'>
                    <tr><td height='30'></td></tr>
                    <tr><td>User Name</td>
                        <td><input type='text' name='userName' size='45'/></td></tr>
                    <tr><td>Library Name</td>
                        <td><select name='libraryNo'>
                        <?php
                            require('db_connection.php');
                            if($userType=='administrator')
                            {
                                $query = "SELECT libraryName FROM tbllibrary WHERE libraryNo='$libraryNo'";
                            }
                          else
                            {
                              $query = "SELECT libraryName, libraryNo FROM tbllibrary";
                            }
                            $result = mysql_query($query);

                            while ($row = mysql_fetch_array($result))
                            {
                                $libraryNo = $row['libraryNo'];
                                $libraryName = $row['libraryName'];
                                echo "<option value='$libraryNo'>"." $libraryName "."";
                            }
                        ?>
                        </select>
                        </td>
                    </tr>
                    <tr><td>First Name</td>
                        <td><input type='text' name='firstName' size='45'/></td></tr>
                    <tr><td>Middle Name</td>
                        <td><input type='text' name='middleName' size='45'/></td></tr>
                    <tr><td>Last Name</td>
                        <td><input type='text' name='lastName' size='45'/></td></tr>
                    <tr><td>Password</td>
                        <td><input type='password' name='password' size='45'/></td></tr>
                    <tr><td>Confirm Password</td>
                        <td><input type='password' name='cpass' size='45'/></td></tr>
                    <tr><td>Address</td>
                        <td><input type='text' name='address' size='45'/></td></tr>
                    <tr><td>Contact No</td>
                        <td><input type='text' name='contactNo' size='45'/></td></tr>
                    <tr><td>E-mail Address</td>
                        <td><input type='text' name='email' size='45'/></td></tr>
                    <tr><td>User Type</td>
                        <td><select name='userType'>
                        <?php
                            if($userType=='superadministrator')
                            {
                                echo "<option value='superadministrator'>Super Administrator</option>";
                                echo "<option value='administrator'>Administrator</option>";
                                echo "<option value='staff'>Staff</option>";
                            }
                            if($userType=='administrator')
                            {
                                echo "<option value='staff'>Staff</option>";
                            }
                            
                        ?>

                        </select>
                        </td>
                    </tr>
                    <tr><td colspan='2' align='right'><input type='submit' value='Save' class='tool'></td></tr>
                </table>
                </form>
                </td>
            </tr>
            <tr><td align='center' colspan='2'><?php require ('copyright.php')?></td></tr>
        </table>
     

   </body>
</html>
